#define _CRT_SECURE_NO_WARNINGS 1


class Solution {
public:
    string addStrings(string num1, string num2)
    {
        int i1 = num1.size() - 1;
        int i2 = num2.size() - 1;

        int next = 0;
        int now = 0;

        int intnum1 = 0;
        int intnum2 = 0;

        string return_string;

        while (i1 >= 0 || i2 >= 0)
        {
            if (i1 >= 0)
            {
                intnum1 = num1[i1--] - '0';
            }
            else
            {
                intnum1 = 0;

            }

            if (i2 >= 0)
            {
                intnum2 = num2[i2--] - '0';
            }
            else
            {
                intnum2 = 0;

            }

            now = (intnum1 + intnum2 + next) % 10;
            next = (intnum1 + intnum2 + next) / 10;

            return_string += ('0' + now);

        }

        if (next == 1)
        {
            return_string += '1';
        }

        reverse(return_string.begin(), return_string.end());

        return return_string;
    }
};